home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 417 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: solon.com!not-for-mail
  2. From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: Re: Integral promotion.
  5. Date: 17 Feb 1996 11:53:29 -0600
  6. Organization: Los Alamos National Laboratory
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4g54mp$agm@solutions.solon.com>
  10. References: <4fstj7$2l6@solutions.solon.com> <4fu835$9de@solutions.solon.com>
  11.     <4fvgrm$dv9@solutions.solon.com> <4g28hr$qko@solutions.solon.com>
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14. In article <4g28hr$qko@solutions.solon.com> thads@csn.net (Thad Smith)
  15. writes: 
  16. <snip>
  17.    In article <4fvgrm$dv9@solutions.solon.com>, msb@sq.com wrote:
  18.    >Oh dear, I have to correct Chris Torek (torek@bsdi.com).  
  19.  
  20.    >Thus even in ANSI C, if this function is called this way:
  21.    >
  22.    >    extern short p, q, r, test(short,short);
  23.    >    r = test(p,q);
  24.    >
  25.    >the values from p and q are still converted from short to int and back
  26.    >to short.  
  27.  
  28.    I find nothing in the Standard that states that the arguments undergo
  29.    integral promotions before being assigned to the function parameters.
  30.  
  31. The way I read the standard (6.2.1.1):
  32.  
  33. ``A char, a short int, or an int bit-field, or their signed or unsigned
  34. varieties, or an enumeration type, may be used in an expression
  35. wherever an int or unsigned int may be used. ...< describing integral
  36. promotions >... these are called integral promotions.''
  37.  
  38. Seems to imply that whenever a value of type `int' is a possibility,
  39. integral promotions always take place. Without enum types, I don't see
  40. how this matters in a function call, as long as implementation defined
  41. behaviour is reasonable (i.e. signed char->int->short is same as
  42. signed char->short etc.)
  43.  
  44. For enums, I am confused. If an enum type is compatible with `long',
  45. does integral _promotion_ narrow it to an int or unsigned int :-)?
  46.  
  47. Cheers
  48. Tanmoy
  49. --
  50. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  51. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  52. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  53. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  54. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  55. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  56.